<template>
	<view class="bgview">
		<!-- 开启下拉刷新和无数据显示图片 1 :empty-view-style="{'margin-top':'-200rpx'}" -->
		<z-paging ref="paging2" v-model="jobsList" @query="getSearchJobData" :fixed="false" :default-page-size="20"
			:loading-more-no-more-text="''" :show-loading-more-no-more-line="false" :auto="false">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
				<view class="view-lint-bg">

					<view class="chanceSearchPage-after">
						<uni-list :border="false">
							<uni-list-item link showArrow :title="item.name" v-for="item in jobsList" :key="item.code"
								@click="onCellClick(item.code)">
							</uni-list-item>
						</uni-list>

					</view>


				</view>


			</scroll-view>

		</z-paging>

		<loading v-show="loadshow"></loading>
	</view>

</template>

<script>
	export default {
		props: {
			datanumber: {
				type: Number,
				default: null
			},
			inputValue: {
				type: String,
				default: ''
			},
			isShowData: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				loadshow: false,
				searchkey: '',
				jobsList: [],
				submodelIndexs: [],
				scrollTop: 0,
				positionBox: 1, //我是职业页面的状态 如果没有数据那么就为空
			}
		},
		methods: {
			getSelectData(e) {

				this.clickSchool = e.detail
			},
			getSearchJobData(page = 1, pageSize = 20) {
				if (this.isShowData == 2) {
					// uni.showLoading({
					// 	mask:true
					// })
				}
				let data = {
					search: this.searchkey,
					searchType: "job",
					page,
					pageSize,
				}
				this.submodelIndexs = []
				this.loadshow = true
				this.$request.searchType(data).then(res => {
					this.loadshow = false
					this.jobsList = res.data[0].data
					if (this.jobsList.length > 0) {
						this.positionBox = 1
						this.$emit("changeBoxIsShow", "jobMsg", 1)
					} else {
						this.positionBox = 2
						this.$emit("changeBoxIsShow", "jobMsg", 0)
					}
					if (this.datanumber == 3 && this.jobsList.length != 0) {
						let newjobsListData = []

						this.jobsList = this.jobsList.slice(0, 1)


					}
					if (this.jobsList.length == 0) {
						this.$emit("isLookMet", "jobMassage")
					}
					this.$userManager.setSeejobData(res.data[0].data)

					this.$refs.paging2.complete(res.data[0].data);
					uni.hideLoading()
				}).catch(err => {
					uni.hideLoading()
					uni.$emit('z-paging-error-emit')
				})
			},

			onCellClick(e) {
				uni.navigateTo({
					url: "/subpackages/subpackage1/pages/seejob/seejobdetail?code=" + e
				})
			},
			isShow(hederIndex, index) {
				let arr = this.submodelIndexs[hederIndex]
				if (!arr) {
					arr = []
				}

				return arr.some(item => item == index)
			},
			// 点击列表执行
			onClickSubmodelCell(headerIndex, index) {
				let arr = this.submodelIndexs[headerIndex]
				if (!arr) {
					this.submodelIndexs[headerIndex] = []
					arr = []
				}

				const findIndex = arr.findIndex(item => item == index)
				if (findIndex >= 0) {
					arr.splice(findIndex, 1)
				} else {
					arr.push(index)
				}

				this.submodelIndexs[headerIndex] = arr
			},

		},
		watch: {
			inputValue: {
				handler() {
					this.searchkey = this.inputValue
					this.getSearchJobData()
					// this.$refs.paging2.reload()
				},
				deep: true,
				immediate: true
			}

		},
		mounted() {
			this.searchkey = this.inputValue
			// this.getSearchJobData()
		}
	}
</script>

<style lang="scss" scoped>
	.bgview {
		height: 100%;
	}

	.view-lint-bg {
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
	}

	// .spaceview {
	// 	background-color: #F8F8F8;
	// 	height: 36rpx;
	// }
	// .see-job-title {
	// 	margin-left: 36rpx;
	// 	font-size: 32rpx;
	// 	height: 86rpx;
	// 	line-height: 86rpx;
	// }
	.content {
		padding: 15px;
		font-size: 14px;
		line-height: 20px;
		color: #666;
	}


	.seejobtitle {
		margin: 36rpx 0 10rpx 32rpx;
		font-size: 32rpx;
		color: #464646;
	}

	.view-list-bg {
		height: 80rpx;
		padding: 0 20rpx 0 32rpx;
	}

	.text-title {
		color: #464646;
		font-size: 28rpx;
		font-weight: bold;
	}

	.text-value {
		color: #999999;
		font-size: 24rpx;
		font-weight: bold;
	}

	.text-job {
		color: #999999;
		font-size: 28rpx;
		font-weight: bold;
		padding: 16rpx 32rpx;
	}

	.cell-select {
		color: #FF3B0A;
	}

	.scroll-Y {
		height: 100%;
	}

	//定位图片盒子
	.positionBox {
		width: 300rpx;
		height: 300rpx;
		position: absolute;
		display: flex;
		flex-direction: column;
		top: calc(50% - 150rpx - 128rpx);
		left: calc(50% - 120rpx);

		image {
			width: 100%;
			height: 80%;
		}

		text {
			width: 100%;
			text-align: center;
		}
	}

	.chanceSearchPage-after {
		max-height: 70vh;
	}
</style>